<template>
  <div class="container">
    <transition :name="transitionName">
      <component :is="currentComponent" style="width: 100%; height: 100%;"/>
    </transition>
    
    <nav class="navigation">
      <button
        v-for="(item, index) in pages" 
        :key="index"
        :class="{ active: currentIndex === index }"
        @click="switchPage(index)"
      >
        {{ item.name }}
      </button>
    </nav>
  </div>
</template>

<script>
import Social from './Social/index.vue'
import Map from './Map/index.vue'
import Me from './Me/index.vue'

export default {
  components: { Social, Map, Me },
  data() {
    return {
      currentIndex: 1,
      transitionName: 'slide-left',
      pages: [
        { name: 'Social', component: 'Social' },
        { name: 'Map', component: 'Map' },
        { name: 'Me', component: 'Me' }
      ]
    }
  },
  computed: {
    currentComponent() {
      return this.pages[this.currentIndex].component
    }
  },
  methods: {
    switchPage(newIndex) {
      this.transitionName = newIndex > this.currentIndex ? 'slide-left' : 'slide-right'
      this.currentIndex = newIndex
    }
  }
}
</script>

<style scoped>
.container {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.container > *:not(.navigation) {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.navigation {
  position: absolute;
  min-width: 300px;
  width: 50%;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: space-around;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid #dfdfdf;
  background: 
    radial-gradient(50px circle at 19% 50%, rgb(231, 57, 57, 0.6), transparent 100%),
    radial-gradient(50px circle at 50% 50%, rgb(231, 187, 57, 0.6), transparent 100%),
    radial-gradient(50px circle at 83.5% 50%, rgb(57, 98, 231, 0.6), transparent 100%),
    rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
}
button:focus,
button:focus-visible {
  outline: none;
}

.slide-left-enter-active,
.slide-left-leave-active,
.slide-right-enter-active,
.slide-right-leave-active {
  transition: transform 0.5s ease;
}

.slide-left-enter-from {
  transform: translateX(100%);
}

.slide-left-leave-to {
  transform: translateX(-100%);
}

.slide-right-enter-from {
  transform: translateX(-100%);
}

.slide-right-leave-to {
  transform: translateX(100%);
}
</style>